package com.object.configuration.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
    Profiles of = Profiles.of("dev", "test");

    @Bean
    public Docket docket(Environment environment) {
        boolean b = environment.acceptsProfiles(of);
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).enable(b).select()
//                在此包下的类就能扫描
                .apis(RequestHandlerSelectors.basePackage("com.student.object.studentobject.controller"))
                .build();
    }
    private ApiInfo apiInfo() {
        Contact contact = new Contact("小云", "https://www.baidu.com/?tn=94819464_hao_pg", "2233859795@qq.com");
        return new ApiInfo(
                "小云",
                "项目",
                "v1.0",
                "https://www.baidu.com/?tn=94819464_hao_pg",
                contact,
                "许可",
                "https://www.baidu.com/?tn=94819464_hao_pg",
                new ArrayList<>()
        );
    }
}